<?php
/**
* 提供统一的DB配置
* @param string $tagname DB的标识符
*/
function commentdbconfig($tagname,$key){
	$user        = null;
  $pass        = null;
  $port        = 8066;
  $database    = null;
  $table       = null;
  $table_alias = null;
  $hash        = md5($key);
  switch ($tagname){
  	case 'sender': //发送评论库
  	$decimal_hash2 = hexdec(substr($hash, 0, 2));
  	$host = '10.150.9.5';
  	$database = 'd_comment_sender';
  	$table = 't_comment_sender';
  	$user = 'ucdbuser';
    $pass = '(qnO-ps:Oi^0F0';
    break;
    case 'receiver'://评论接收表
    $decimal_hash2 = hexdec(substr($hash, 0, 2));
  	$host = '10.150.9.5';
  	$database = 'd_comment_receiver';
  	$table = 't_comment_receiver';
  	$user = 'ucdbuser';
    $pass = '(qnO-ps:Oi^0F0';
    break;
    case 'module': //对象评论
    $decimal_hash2 = hexdec(substr($hash, 0, 2));
    $host = '10.150.9.5';
   	$database = 'd_comment_module';
  	$table = 't_comment_module';
  	$user = 'ucdbuser';
    $pass = '(qnO-ps:Oi^0F0';
    break;
    case 'visitors': //谁来看过我访问信息
    $host = '10.150.9.5';
    $database = 'd_visitor';
    $table = 't_visitor_visit';
    $user = 'ucdbuser';
    $pass = '(qnO-ps:Oi^0F0';
    break;
    case 'browse': //我去看过谁访问信息
    $host = '10.150.9.5';
    $database = 'd_visitor';
    $table = 't_visitor_browse';
    $user = 'ucdbuser';
    $pass = '(qnO-ps:Oi^0F0';
    break;
    case 'spread': //推广条数据
    $host = '10.150.9.5';
    $database = 'd_article_promotion';
    $table = 't_article_promotion';
    $user = 'ucdbuser';
    $pass = '(qnO-ps:Oi^0F0';
    break;
    case 'spreaduser': //推广条用户
    $host = '10.150.9.5';
    $database = 'd_article_user';
    $table = 't_article_user';
    $user = 'ucdbuser';
    $pass = '(qnO-ps:Oi^0F0';
    break;
    case 'activeuser': //活跃用户
    $host = '10.150.9.5';
    $database = 'd_activeuser';
    $table = 't_activeuser';
    $user = 'ucdbuser';
    $pass = '(qnO-ps:Oi^0F0';
    break;
    default :
    $ret = array();
    return $ret;
  }
  if(__UC_ENV == 'DEV') {
  	$host = '10.129.128.14';
  	$user = "root";
    $pass = "123qwe";
    $port = 3306;
  }else if(__UC_ENV == 'TEST'){
  	$host = '10.10.85.4';
  	$user = "ucdbuser";
    $pass = "sdf2w@!w";
    $port = 8066;
  }
  $ret = array(
				'driver' => 'mysql',
				'host' => $host,
				'port' => $port,
				'username' => is_null($user) ? "root" : $user,
				'password' => is_null($pass) ? "123qwe" : $pass,
				'database' => $database,
				'table' => $table  
		);
		return $ret;
}
?>